//
// Created by YE on 2024/1/19.
//

#ifndef YCH_INTERPRETER_EXECUTOR_H
#define YCH_INTERPRETER_EXECUTOR_H
#include "instruction.h"
#include "memory.h"
#include "../common/ych_object.h"

typedef Instruction* PC;
typedef struct Ps_State{
    Ps_State* pre;
    unsigned int param_stack_start;
    unsigned int params;
    Instruction* return_ip;
}Ps_State;
typedef struct GC_Node{
    GC_Node* pre;
    Mat* mat;
}*GC_List;
struct Vm_State{
    unsigned int stack_top;
    Ps_State* ps;
    PC pc;
    GC_List gcList;
    bool need_gc;
};

typedef YCH_STATE Executor_State;
class Executor{
public:
    Executor();
    ~Executor();
    Vm_State* vm_state;
    Executor_State execute() const;
};
#endif //YCH_INTERPRETER_EXECUTOR_H
